/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.herenit.beijing.dh2011.security.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Obama
 */
@Entity
@Table(name = "SECURITY_ROLE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SecurityRole.findAll", query = "SELECT s FROM SecurityRole s"),
    @NamedQuery(name = "SecurityRole.findByRoleId", query = "SELECT s FROM SecurityRole s WHERE s.roleId = :roleId"),
    @NamedQuery(name = "SecurityRole.findByRoleName", query = "SELECT s FROM SecurityRole s WHERE s.roleName = :roleName"),
    @NamedQuery(name = "SecurityRole.findByRoleCode", query = "SELECT s FROM SecurityRole s WHERE s.roleCode = :roleCode"),
    @NamedQuery(name = "SecurityRole.findByCreatorName", query = "SELECT s FROM SecurityRole s WHERE s.creatorName = :creatorName"),
    @NamedQuery(name = "SecurityRole.findByCreateTime", query = "SELECT s FROM SecurityRole s WHERE s.createTime = :createTime"),
    @NamedQuery(name = "SecurityRole.findByUpdaterName", query = "SELECT s FROM SecurityRole s WHERE s.updaterName = :updaterName"),
    @NamedQuery(name = "SecurityRole.findByUpdateTime", query = "SELECT s FROM SecurityRole s WHERE s.updateTime = :updateTime"),
    @NamedQuery(name = "SecurityRole.findByRoleDesc", query = "SELECT s FROM SecurityRole s WHERE s.roleDesc = :roleDesc")})
public class SecurityRole implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "ROLE_ID")
    private String roleId;
    @Size(max = 30)
    @Column(name = "ROLE_NAME")
    private String roleName;
    @Size(max = 20)
    @Column(name = "ROLE_CODE")
    private String roleCode;
    @Size(max = 20)
    @Column(name = "CREATOR_NAME")
    private String creatorName;
    @Column(name = "CREATE_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
    @Size(max = 20)
    @Column(name = "UPDATER_NAME")
    private String updaterName;
    @Column(name = "UPDATE_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;
    @Size(max = 200)
    @Column(name = "ROLE_DESC")
    private String roleDesc;
    @OneToMany(mappedBy = "roleId")
    private List<SecurityAccountRole> securityAccountRoleList;
    @OneToMany(mappedBy = "roleId")
    private List<SecurityMenuRole> securityMenuRoleList;
    @OneToMany(mappedBy = "fatherId")
    private List<SecurityRole> securityRoleList;
    @JoinColumn(name = "FATHER_ID", referencedColumnName = "ROLE_ID")
    @ManyToOne
    private SecurityRole fatherId;
    @OneToMany(mappedBy = "roleId")
    private List<SecurityAccRolePermission> securityAccRolePermissionList;

    public SecurityRole() {
    }

    public SecurityRole(String roleId) {
        this.roleId = roleId;
    }

    public String getRoleId() {
        return roleId;
    }

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRoleCode() {
        return roleCode;
    }

    public void setRoleCode(String roleCode) {
        this.roleCode = roleCode;
    }

    public String getCreatorName() {
        return creatorName;
    }

    public void setCreatorName(String creatorName) {
        this.creatorName = creatorName;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getUpdaterName() {
        return updaterName;
    }

    public void setUpdaterName(String updaterName) {
        this.updaterName = updaterName;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getRoleDesc() {
        return roleDesc;
    }

    public void setRoleDesc(String roleDesc) {
        this.roleDesc = roleDesc;
    }

    @XmlTransient
    public List<SecurityAccountRole> getSecurityAccountRoleList() {
        return securityAccountRoleList;
    }

    public void setSecurityAccountRoleList(List<SecurityAccountRole> securityAccountRoleList) {
        this.securityAccountRoleList = securityAccountRoleList;
    }

    @XmlTransient
    public List<SecurityMenuRole> getSecurityMenuRoleList() {
        return securityMenuRoleList;
    }

    public void setSecurityMenuRoleList(List<SecurityMenuRole> securityMenuRoleList) {
        this.securityMenuRoleList = securityMenuRoleList;
    }

    @XmlTransient
    public List<SecurityRole> getSecurityRoleList() {
        return securityRoleList;
    }

    public void setSecurityRoleList(List<SecurityRole> securityRoleList) {
        this.securityRoleList = securityRoleList;
    }

    public SecurityRole getFatherId() {
        return fatherId;
    }

    public void setFatherId(SecurityRole fatherId) {
        this.fatherId = fatherId;
    }

    @XmlTransient
    public List<SecurityAccRolePermission> getSecurityAccRolePermissionList() {
        return securityAccRolePermissionList;
    }

    public void setSecurityAccRolePermissionList(List<SecurityAccRolePermission> securityAccRolePermissionList) {
        this.securityAccRolePermissionList = securityAccRolePermissionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (roleId != null ? roleId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SecurityRole)) {
            return false;
        }
        SecurityRole other = (SecurityRole) object;
        if ((this.roleId == null && other.roleId != null) || (this.roleId != null && !this.roleId.equals(other.roleId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.herenit.beijing.dh2011.security.SecurityRole[ roleId=" + roleId + " ]";
    }
    
}
